/****************************************************************************
*
*					Functions of class InferenceFactory
*
****************************************************************************/

#include "InferenceFactory.h"
#include "AllInferenceClasses.h"


/****************************************************************************
*					InferenceFactory::InferenceFactory
*
*	Description:	Standard constructor with initialization of internal parameters
*	Parameters:		-
*	Returns:		-
*
****************************************************************************/
InferenceFactory::InferenceFactory (void) {
	
}


/****************************************************************************
*					InferenceFactory::~InferenceFactory
*
*	Description:	Standard destructor with removing all dynamic internal variables
*	Parameters:		-
*	Returns:		-
*
****************************************************************************/
InferenceFactory::~InferenceFactory (void) {
	
}


/****************************************************************************
*					InferenceFactory::createObjectByID
*
*	Description:	Function creates object of ancestor class Inference
*					of a subclass with a given ID
*	Parameters:		id - identificator of subclass of class Inference
*	Returns:		Inference* - new dynamic object of subclass of 
*						Inference with the given ID
*
****************************************************************************/
Inference* InferenceFactory::createObjectByID(const signed int id) {
	// Dummy
	return NULL;
}


/****************************************************************************
*					InferenceFactory::createObjectByName
*
*	Description:	Function creates object of ancestor class Inference
*					of a subclass with a given name
*	Parameters:		name - name of the desired subclass of class Inference
*	Returns:		Inference* - new dynamic object of subclass of 
*						Inference with the given name
*
****************************************************************************/
Inference* InferenceFactory::createObjectByName(const std::string name) {
	// Transforming to lowercase
	std::string nameStr (name);
	std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), ::tolower);
	
	// Comparing the names
	if ((strcmp (nameStr.c_str(), "loopybp") == 0) || (strcmp (nameStr.c_str(), "loopy") == 0) ) {
		return new LoopyBP();
	}
	if (strcmp (nameStr.c_str(), "exact") == 0) {
		return new ExactInference();
	}

	// Returning the NULL value
	Inference* inference = NULL;
	return inference;
}
